<template>
	<view class="wrap">
		<view class="content">
			<view class="title">欢迎登录</view>
			<u-form :model="form" ref="uForm" :label-width="130">
				<u-form-item label="手机号">
					<input type="number" :maxlength="11" v-model="form.loginName" placeholder="请输入手机号" />
				</u-form-item>
			</u-form>
			
			<!-- <view class="tips">未注册的手机号验证后自动创建账号</view> -->
			<u-button @click="submit" :style="[inputStyle]" class="getCaptcha">获取短信验证码</u-button>
			<!-- <view class="alternative">
				<view class="account" @click="accountLogin">密码登录</view>
				<view class="issue" @click="problem">遇到问题</view>
			</view> -->
		</view>
		<!-- <view class="buttom">
			<view class="loginType">
				<view class="wechat item">
					<view class="icon"><u-icon size="60" name="server-man" color="#999" @click="server"></u-icon></view>
				</view>
			</view>
		</view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form:{
					loginName: undefined
				}
			}
		},
		onLoad() {
			// // 在页面中定义激励视频广告
			// let videoAd = null
			// // 在页面onLoad回调事件中创建激励视频广告实例
			// if (wx.createRewardedVideoAd) {
			// 	videoAd = wx.createRewardedVideoAd({
			// 		adUnitId: 'adunit-8cd5789a01a51891'
			// 	})
			// 	videoAd.onLoad(() => {})
			// 	videoAd.onError((err) => {})
			// 	videoAd.onClose((res) => {})
			// }
			// // 用户触发广告后，显示激励视频广告
			// if (videoAd) {
			// 	videoAd.show().catch(() => {
			// 		// 失败重试
			// 		videoAd.load()
			// 			.then(() => videoAd.show())
			// 			.catch(err => {
			// 				console.log('激励视频 广告显示失败')
			// 			})
			// 	})
			// }
		},
		computed: {
			// 小程序端无效
			inputStyle() {
				let style = {};
				if (this.form.loginName && this.$u.test.mobile(this.form.loginName)) {
					style.color = "#fff";
					style.backgroundColor = this.$u.color['primary'];
				}
				return style;
			}
		},
		methods: {
			submit() {
				if (this.$u.test.mobile(this.form.loginName)) {
					this.$u.route({
						url: 'pages/login/code',
						params: {
							loginName: this.form.loginName
						}
					})
				} else {
					this.$mytip.toast('请输入有效的手机号码')
				}
			},
			accountLogin() {
				this.$u.route({
					url: '/pages/login/account'
				})
			},
			problem() {
				this.$u.route({
					url: 'pages/login/problem'
				})
			},
			server() {
				window.open('https://sourcebyte.cn')
			}
		}
	};
</script>

<style>
	page {
		overflow: hidden;
		background-color: #ffffff;
	}
</style>
<style lang="scss" scoped>
	.wrap {
		font-size: 28rpx;

		.content {
			width: 600rpx;
			margin: 80rpx auto 0;

			.title {
				text-align: left;
				font-size: 60rpx;
				font-weight: 500;
				margin-bottom: 100rpx;
			}

			input {
				text-align: left;
				margin-bottom: 10rpx;
				padding-bottom: 6rpx;
			}

			.tips {
				color: $u-type-info;
				margin-bottom: 60rpx;
				margin-top: 8rpx;
			}

			.getCaptcha {
				background-color: rgba(0, 0, 0, .1);
				color: $u-tips-color;
				border: none;
				font-size: 30rpx;
				padding: 12rpx 0;
				margin-top: 40rpx;
				width: 50%;

				&::after {
					border: none;
				}
			}

			.alternative {
				color: $u-tips-color;
				display: flex;
				justify-content: space-between;
				margin-top: 30rpx;

				.account {
					&:active {
						background-color: #ededed;
					}
				}
			}
		}

		.buttom {
			.loginType {
				font-size: 14px;
				position: fixed;
				right: 50rpx;
				bottom: 50rpx;
				width: 60px;
				height: 60px;
				padding: 4px;
				cursor: pointer;
				background: #FFF;
				text-align: center;
				line-height: 60px;
				border-radius: 100%;
				-webkit-box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, 0.1), inset 0px -1px 0px 0px rgba(0, 0, 0, 0.1);
				box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, 0.1), inset 0px -1px 0px 0px rgba(0, 0, 0, 0.1);
			}
		}
	}
</style>